import java.net.SocketPermission;

/**
 * Created by h p on 2016/5/12.
 */
public class gcd {
    public static void main(String[] args) {
        int m=1000;
        int n=495;
        int p=0;
        while(m%n!=0){
            p=m%n;
            m=n;
            n=p;
        }
        System.out.println(n);
    }

}
